using System.Collections;
using System.Collections.Generic;
using FairyGUI;
using UnityEngine;

namespace YanhuaMMO
{
    public class CustomGLoader : GLoader
    {
        private string _assetName = "";

        public CustomGLoader()
        {
        }

        protected override void LoadExternal()
        {
            ResourceManager.Instance.LoadSpritePrefab(url, delegate (Sprite sp)
            {
                _assetName = url;
                onExternalLoadSuccess(new NTexture(sp.texture));
            });
        }

        
        protected override void FreeExternal(NTexture texture)
        {
            if ( _assetName.Length > 0 )
            {
                ResourceManager.Instance.UnloadSpitePrefab(_assetName);
            }
        }
        

        public override void Dispose()
        {
            base.Dispose();
            if (_assetName.Length > 0)
            {
                ResourceManager.Instance.UnloadSpitePrefab(_assetName);
            }
        }
    }
}

